<template>
	<view class="container">
		<view class="show p10">
			<view class="title">{{detail.title || ''}}</view>
			<view class="t">
				<text class="fl">{{detail.createtime || ''}}</text>
				<text class="fr">浏览：{{detail.browse || '0'}}</text>
			</view>
			<view class="txt">
				<rich-text :nodes="detail.content"></rich-text>
			</view>
		</view>	
		<view class="show p10 bor10">	
			<comment :contentId="detail.id" type="ask"></comment>
		</view>
	</view>
</template>

<script>
	import rand from '@/common/random.js'
	import favorite from '@/components/favorite';
	import comment from '@/components/comment';
	export default{
		components: {
			favorite: favorite,
			comment: comment
		},
		data() {
			return {
				id: 0, //id
				content: null,
				txt: '',
				detail: {},
			};
		},
		onLoad(option) {
			console.log('参数',option);
			if(option && option.id){
				this.id = option.id;
			}
			this.loadData();
			
		},
		methods: {
			async loadData() {
				
				await this.$http.post('api/article/detail',{id: this.id}).then(res=>{
					if(res.code === this.sucCode){
						this.detail = res.data || {};
						if(this.detail.title){
							uni.setNavigationBarTitle({
								title: this.detail.title
							});
						}
						
					}else{
						this.$mHelper.toast(res.msg);
					}
				}).catch(err=>{
					console.log(err);
				})
			},
			
			/* async loadData() {
				let outline = await this.$api.json('outline');
				this.outline = outline;
			}, */
		}
	}
</script>

